{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 5.2 创建矩阵\n",
    "# mat函数创建矩阵时，若输入已为matrix或者ndarray对象，则不会为他们创建副本。\n",
    "# 因此，用mat函数和调用matrix(data, copy=False）等价。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ True  True  True]\n [ True  True  True]\n [ True  True  True]]\n[[0 2 0]\n [2 2 0]\n [0 1 0]]\n[[-1 -1  1]\n [-1  0  1]\n [ 1  1 -1]]\n[[-2  0  2]\n [-4 -2  4]\n [-1  0  1]]\n"
     ]
    }
   ],
   "source": [
    "# （1）在创建矩阵的专用字符串中， 矩阵的行与行之间用【分号】隔开，行内的元素之间用【空格】隔开\n",
    "import numpy as np\n",
    "\n",
    "A = np.mat('0 2 0; 2 2 0; 0 1 0')\n",
    "B = np.mat('-1, -1 1; -1 0 1; 1 1 -1')\n",
    "C = A.dot(B)\n",
    "D = np.dot(A, B)\n",
    "print(C == D)\n",
    "print(A)\n",
    "print(B)\n",
    "print(C)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    ""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2.0
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}